﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Loops - break operator</title>
	<link href="styles/js-console.css" rel="stylesheet" />
</head>
<body>
	<input type="text" id="tb-number" />
	<a href="#" id="btn-check-prime" onclick="onCalcFactBtnClick()">Calc factorial</a>
	<div id="js-console">
	</div>
	<script src="scripts/js-console.js">	  
	</script>
	<script>
		function onCalcFactBtnClick() {

			var number = jsConsole.readInteger("#tb-number");
			var fact = 1;
			var factStr = "n! = ";
			while (true) {
				if (number == 1)
					break;
				factStr += number + "*"
				fact *= number;
				number--;
			}
			factStr += "1 = " + fact;
			jsConsole.writeLine(factStr);
		}

	</script>
</body>
</html>
